package com.ruoyi.system.service.impl;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.WarnUserLogExcel;
import com.ruoyi.system.enums.AssessmentStatus;
import com.ruoyi.system.mapper.InterviewLogMapper;
import com.ruoyi.system.service.IInterviewLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.WarnUserLogMapper;
import com.ruoyi.system.domain.WarnUserLog;
import com.ruoyi.system.service.IWarnUserLogService;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-06-14
 */
@Service
public class WarnUserLogServiceImpl implements IWarnUserLogService 
{
    @Autowired
    private WarnUserLogMapper warnUserLogMapper;
    /**
     * 查询【请填写功能名称】
     * 
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public WarnUserLog selectWarnUserLogById(Long id)
    {
        return warnUserLogMapper.selectWarnUserLogById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param warnUserLog 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<WarnUserLog> selectWarnUserLogList(WarnUserLog warnUserLog)
    {
        return warnUserLogMapper.selectWarnUserLogList(warnUserLog);
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param warnUserLog 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertWarnUserLog(WarnUserLog warnUserLog)
    {
        warnUserLog.setCreateTime(DateUtils.getNowDate());
        return warnUserLogMapper.insertWarnUserLog(warnUserLog);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param warnUserLog 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateWarnUserLog(WarnUserLog warnUserLog)
    {
        return warnUserLogMapper.updateWarnUserLog(warnUserLog);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteWarnUserLogByIds(Long[] ids)
    {
        return warnUserLogMapper.deleteWarnUserLogByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteWarnUserLogById(Long id)
    {
        return warnUserLogMapper.deleteWarnUserLogById(id);
    }

    @Override
    public Map<String, Object> selectWarnUserLogStatistics(WarnUserLog warnUserLog) {
        Map<String,Object> result = new HashMap<>();
        //预警数据
        result.put("data1",warnUserLogMapper.selectWarnUserLogStatistics(warnUserLog,AssessmentStatus.list()));
        //第二阶段访谈进度
        result.put("data2",warnUserLogMapper.selectInterviewStatistics(warnUserLog));
        return result;
    }

    @Override
    public List<WarnUserLogExcel> selectWarnUserLogExcelList(WarnUserLog warnUserLog) {
        List<WarnUserLogExcel>  list =  warnUserLogMapper.selectWarnUserLogExcelList(warnUserLog);
        for (WarnUserLogExcel warnUserLogExcel : list) {
            warnUserLogExcel.setRoleName("学生");
            if(warnUserLogExcel.getLevelJudge() == 1){
                warnUserLogExcel.setLevelJudgeText("评测预警");
            }
            warnUserLogExcel.setSexText(warnUserLogExcel.getSex() == 1 ? "男" : "女");
        }
        return list;
    }
}
